﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.OleDb; 

using DbSharp.Framework.DbObject;
using DbSharp.Framework.Driver;
using System.Data;
using DbSharp.Framework.Driver.FieldPersistence;


namespace DbSharp.Framework.Driver
{

    public interface ITestDataSource
    {
        /// <summary>
        /// to retrieve the current datetime in database server. 
        /// 
        /// it is only used in software expiration checking, so it is not necessary to get timezone
        /// </summary>
        /// <param name="conn">database connection object</param>
        /// <returns>current datetime</returns>
        DateTime GetDbServerTime(DbConnection conn);

        /// <summary>
        /// check the given ArgumentType is one recordset or not
        /// </summary>
        /// <param name="argumentTypeText">argumentType name</param>
        /// <returns>true if argument is cursor or recordset</returns>
        bool IsRecordsetTypeArgument(string argumentTypeText);

        /// <summary>
        /// check the given param is one recordset or not
        /// 
        /// This function does not used at all for DBs which supports anonymous-output-type argument.
        /// For these type of database, use IsRecordsetTypeArgument() method instead
        /// </summary>
        /// <param name="param">DbParameter object</param>
        /// <returns></returns>
        bool IsRecordsetTypeParameter(DbParameter param);


        /// <summary>
        /// to create one specific datebase connection object 
        /// </summary>
        /// <param name="connString">connection string</param>
        /// <returns></returns>
        DbConnection CreateConnection(string connString);


        /// <summary>
        /// initialize one DbCommand object according to statement demanding
        /// </summary>
        /// <param name="statement">SqlStatement or ProcedureStatement</param>
        /// <returns>DbCommand object</returns>
        DbCommand PrepareCommand(IStatementDeclaration statement);


        /// <summary>
        /// update the CommandText property of DbCommand object 
        /// </summary>
        /// <param name="cmd">command object</param>
        /// <param name="newCmdText">new command text</param>
        void UpdateCommandText(DbCommand cmd, string newCmdText);


        /// <summary>
        /// Assign parameter value.  
        /// 
        /// About datetimeFormat, http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx
        /// </summary>
        /// <param name="param">DbParameter object</param>
        /// <param name="value">value </param>
        /// <param name="dateTimeFormat">For datetime type DbParameter, dateTimeFormat is format of input value, so it need to parse the value string into datetime </param>
        void AssignParameterValue(DbParameter param, string value, string dateTimeFormat);

        /// <summary>
        /// indicate the database support transaction or not 
        /// </summary>
        bool TransactionSupported { get; }


        /// <summary>
        /// indicate that the datebase supports anonymous-output-type argument or not
        /// </summary>
        bool HoldResultsetMustWithNamedArgInSP { get; }


        /// <summary>
        /// Normalize argument name in order to meet the needs of the specific database server, 
        /// e.g. prefix @ at the begin of the argument name for SQL SERVER
        /// </summary>
        /// <param name="argumentName">argumentName</param>
        /// <returns>normalized argument name</returns>
        string NormalizeArgumentName(string argumentName);



        /// <summary>
        /// Get the service object for field persistence
        /// </summary>
        IFieldPersistence FieldPersistenceService { get; }

    }
    
   
     



}
